<script>
import { normal_option } from '../common'
import Base from './Base'

export default {
  name: 'ChartBar',
  mixins: [Base],
  data() {
    return {
      defaultOption: {
        ...normal_option,
        grid: {
          left: 100,
          right: 25,
          bottom: 25,
          top:25
        },
        yAxis: {
          show: true,
          type: 'category',
          axisLine: {
            show: true
          },// 坐标轴线
          axisTick: {
            show: false
          },// 坐标轴刻度
          axisLabel: {
            show: true
          },// 坐标轴标签
          splitLine: {
            show: false
          }
        },
        xAxis: {
          type: 'value',
          axisLine: {
            show: false
          },
          axisTick: {
            show: false
          },// 坐标轴刻度
          axisLabel: {
            show: true
          },// 坐标轴标签
          splitLine: {
            show: true,
            lineStyle: {
              type: 'dashed'
            }
          }
        },
        series: []
      },
      defaultSeries: {
        type: 'bar',
        barWidth: 20,// 柱子宽度
           // barGap: 0// 不同系列柱子间距
      }
    }
  },
  computed: {
    option: function() {
      let series = [], length = this.dataset.dimensions.length - 1
      let color = this.dataset.option && this.dataset.option.color ? this.dataset.option.color : []
      for (let i = 0; i < length; i++) {
        series.push({
          ...this.defaultSeries
        })
      }

      return {
        ...this.defaultOption,
        dataset: this.dataset,
        series,
        color
      }
    }
  }
}
</script>
